Skip to content

[WPB-23806] (Un-)suspend apps if en-/disabled in the team.#5177

Open
fisx wants to merge 8 commits intodevelopfrom
WPB-23806-_un-_suspend-apps-if-en-_disabled-in-the-team
Open

[WPB-23806] (Un-)suspend apps if en-/disabled in the team.#5177
fisx wants to merge 8 commits intodevelopfrom
WPB-23806-_un-_suspend-apps-if-en-_disabled-in-the-team

Conversation

@fisx
Copy link
Copy Markdown
Contributor

@fisx fisx commented Apr 11, 2026

https://wearezeta.atlassian.net/browse/WPB-23806

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Apr 11, 2026
@fisx fisx force-pushed the WPB-23806-_un-_suspend-apps-if-en-_disabled-in-the-team branch from b270ee6 to b1dd185 Compare April 15, 2026 06:55
- add SetAccountStatus, GetAppIdsForTeam to BrigAPIAccess,
- remove UserProfileFilter,
- revert GetLocalUserProfilesFiltered to GetLocalUserProfiles,
- introduce GetLocalAppProfilesOnly (dedicated & scalable),
- instance SetFeatureConfig AppsConfig now (un-)suspends all apps in team.
@fisx fisx force-pushed the WPB-23806-_un-_suspend-apps-if-en-_disabled-in-the-team branch from b1dd185 to 67e1718 Compare April 15, 2026 08:31
@fisx fisx requested a review from Copilot April 15, 2026 11:37
@fisx fisx marked this pull request as ready for review April 15, 2026 11:38
@fisx fisx requested review from a team as code owners April 15, 2026 11:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements app account (un-)suspension when the team-level apps feature is toggled, by wiring Galley’s team feature updates to Brig account-status updates and adding supporting internal APIs.

Changes:

  • Add Galley AppsConfig feature hook to suspend/unsuspend all app users in a team via Brig.
  • Add Brig internal endpoint to list app user IDs for a team, plus corresponding BrigAPIAccess RPC calls.
  • Refactor Brig public “get app(s)” logic and extend UserSubsystem with GetLocalAppProfilesOnly, plus an integration test covering the suspend/unsuspend behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
services/galley/src/Galley/API/Teams/Features.hs On apps feature enable/disable, fetch team app IDs from Brig and set their account status accordingly.
services/brig/src/Brig/API/Public.hs Adjust app profile retrieval/listing to use the updated UserSubsystem API and a team-app-only path.
services/brig/src/Brig/API/Internal.hs Add internal handler to return app user IDs for a team (for Galley to consume).
libs/wire-subsystems/test/unit/Wire/MockInterpreters/UserSubsystem.hs Update mock interpreter for new UserSubsystem constructors.
libs/wire-subsystems/src/Wire/UserSubsystem/Interpreter.hs Implement GetLocalUserProfiles and new GetLocalAppProfilesOnly using AppStore.
libs/wire-subsystems/src/Wire/UserSubsystem.hs Remove UserProfileFilter API and add GetLocalAppProfilesOnly to the effect API.
libs/wire-subsystems/src/Wire/BrigAPIAccess/Rpc.hs Add RPC calls for listing team app IDs and setting account status.
libs/wire-subsystems/src/Wire/BrigAPIAccess.hs Expose new Brig API access operations in the effect.
libs/wire-api/src/Wire/API/Routes/Internal/Brig.hs Add the internal route definition for GET /i/teams/:tid/apps.
integration/test/Test/FeatureFlags/Apps.hs Add integration test asserting apps are suspended on disable and reactivated on enable.
changelog.d/3-bug-fixes/WPB-23806-_un-_suspend-apps-if-en-_disabled-in-the-team Changelog entry for the behavior change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/wire-subsystems/src/Wire/UserSubsystem.hs
Comment thread libs/wire-subsystems/src/Wire/UserSubsystem/Interpreter.hs Outdated
fisx and others added 4 commits April 15, 2026 13:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This reverts commit 82eb5b3.
Copy link
Copy Markdown
Contributor

@battermann battermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If apps are suspended will they be removed from their conversations? (I hope not, so just checking)

Otherwise I would prefer to replace the zipWith with something more robust.

GetLocalUserProfilesFiltered :: UserProfileFilter -> Local [UserId] -> UserSubsystem m [UserProfile]
GetLocalUserProfiles :: Local [UserId] -> UserSubsystem m [UserProfile]
-- | Get profiles for all app users in a team, touching only the apps table (efficient).
GetLocalAppProfilesOnly :: Local TeamId -> UserSubsystem m [UserProfile]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the "Only" suffix. But that is a super opinionated nit-pick.

Comment on lines +511 to +517
appIds <- getAppIdsForTeam tid
-- NB: this will work as long as the only reason for suspending
-- apps is "payment plan expired", but should we ever introduce a
-- suspend button for team admins to let them temporarily disable
-- apps without deinstalling them, then we need to keep track of
-- the suspend reason and filter for the right one here.
for_ appIds $ \uid -> setAccountStatus uid newStatus
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do this more efficiently on the DB level? (nit-pick)

Comment on lines +508 to +517
let newStatus = case feat.status of
FeatureStatusEnabled -> Active
FeatureStatusDisabled -> Suspended
appIds <- getAppIdsForTeam tid
-- NB: this will work as long as the only reason for suspending
-- apps is "payment plan expired", but should we ever introduce a
-- suspend button for team admins to let them temporarily disable
-- apps without deinstalling them, then we need to keep track of
-- the suspend reason and filter for the right one here.
for_ appIds $ \uid -> setAccountStatus uid newStatus
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could consider to only update the status if the feature status actually changes. Currently any update of the feature (e.g. lockstatus, config) would trigger re-applying the same user status to the apps. not sure if this is really an issue.

getLocalAppProfilesOnlyImpl ltid = do
apps <- AppStore.getApps (tUnqualified ltid)
profiles <- getUserProfilesLocalPart Nothing (ltid $> map (.id) apps)
pure (zipWith injectPreloadedApp profiles apps)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this (zipWith) seems brittle. what if apps and profiles are not ordered in the same way, or contain unequal number of elements?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants